home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / XAMPP 1.4.14 / xampp-win32-1.4.14-installer.exe / xampp / php / pear / Mail / Queue / Body.php next >
PHP Script  |  2004-03-24  |  8KB  |  335 lines

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP Version 4                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2003 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 2.0 of the PHP license,       |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available at through the world-wide-web at                           |
  11. // | http://www.php.net/license/2_02.txt.                                 |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Authors: Radek Maciaszek <chief@php.net>                             |
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id: Body.php,v 1.7 2004/02/29 09:13:32 quipo Exp $
  20.  
  21. /**
  22. * Class contains mail data.
  23. *
  24. * @version  $Revision: 1.7 $
  25. * @author   Radek Maciaszek <chief@php.net>
  26. */
  27.  
  28. /**
  29. * Mail_Queue_Body contains mail data
  30. *
  31. * @author   Radek Maciaszek <wodzu@pomocprawna.info>
  32. * @version  $Revision: 1.7 $
  33. * @package  Mail_Queue
  34. * @access   public
  35. */
  36. class Mail_Queue_Body {
  37.  
  38.     /**
  39.      * Ident
  40.      *
  41.      * @var integer
  42.      */
  43.     var $id;
  44.  
  45.     /**
  46.      * Create time
  47.      *
  48.      * @var string
  49.      */
  50.     var $create_time;
  51.  
  52.     /**
  53.      * Time to send mail
  54.      *
  55.      * @var string
  56.      */
  57.     var $time_to_send;
  58.  
  59.     /**
  60.      * Time when mail was sent
  61.      *
  62.      * @var string
  63.      */
  64.     var $sent_time = null;
  65.  
  66.     /**
  67.      * User id - who send mail
  68.      * MAILQUEUE_UNKNOWN - not login user (guest)
  69.      * MAILQUEUE_SYSTEM - mail send by system
  70.      *
  71.      * @var string
  72.      */
  73.     var $id_user = MAILQUEUE_SYSTEM;
  74.  
  75.     /**
  76.      * use IP
  77.      *
  78.      * @var string
  79.      */
  80.     var $ip;
  81.  
  82.     /**
  83.      * Sender email
  84.      *
  85.      * @var string
  86.      */
  87.     var $sender;
  88.  
  89.     /**
  90.      * Reciepient email
  91.      *
  92.      * @var string
  93.      */
  94.     var $recipient;
  95.  
  96.     /**
  97.      * Email headers (in RFC)
  98.      *
  99.      * @var string
  100.      */
  101.     var $headers;
  102.  
  103.     /**
  104.      * Email body (in RFC) - could have attachments etc
  105.      *
  106.      * @var string
  107.      */
  108.     var $body;
  109.  
  110.     /**
  111.      * How many times mail was sent
  112.      *
  113.      * @var integer
  114.      */
  115.     var $try_sent = 0;
  116.  
  117.     /**
  118.      * Delete mail from database after success send
  119.      *
  120.      * @var bool
  121.      */
  122.     var $delete_after_send = true;
  123.  
  124.     /**
  125.      * Mail_Queue_Body::Mail_Queue_Body() constructor
  126.      *
  127.      * @param integer $id Mail ident
  128.      * @param string $create_time  Create time
  129.      * @param strine $time_to_send  Time to send
  130.      * @param string $sent_time  Sent time
  131.      * @param integer $id_user  Sender user id (who sent mail)
  132.      * @param string $ip Sender user ip
  133.      * @param strine $sender  Sender e-mail
  134.      * @param string $recipient Reciepient e-mail
  135.      * @param string $headers Mail headers (in RFC)
  136.      * @param string $body Mail body (in RFC)
  137.      * @param integer $try_sent  How many times mail was sent
  138.      *
  139.      * @return void
  140.      *
  141.      * @access public
  142.      **/
  143.     function Mail_Queue_Body($id, $create_time, $time_to_send, $sent_time, $id_user,
  144.                        $ip, $sender, $recipient, $headers, $body,
  145.                        $delete_after_send=true, $try_sent=0)
  146.     {
  147.         $this->id                = $id;
  148.         $this->create_time       = $create_time;
  149.         $this->time_to_send      = $time_to_send;
  150.         $this->sent_time         = $sent_time;
  151.         $this->id_user           = $id_user;
  152.         $this->ip                = $ip;
  153.         $this->sender            = $sender;
  154.         $this->recipient         = $recipient;
  155.         $this->headers           = $headers;
  156.         $this->body              = $body;
  157.         $this->delete_after_send = $delete_after_send;
  158.         $this->try_sent          = $try_sent;
  159.     }
  160.  
  161.     /**
  162.      * Mail_Queue_Body::getId()
  163.      *
  164.      * @return integer  Sender id
  165.      * @access public
  166.      **/
  167.     function getId()
  168.     {
  169.         return $this->id;
  170.     }
  171.  
  172.     /**
  173.      * Return mail create time.
  174.      *
  175.      * Mail_Queue_Body::getCreateTime()
  176.      *
  177.      * @return string  Mail create time
  178.      * @access public
  179.      **/
  180.     function getCreateTime()
  181.     {
  182.         return $this->create_time;
  183.     }
  184.  
  185.     /**
  186.      * Return time to send mail.
  187.      *
  188.      * Mail_Queue_Body::getTimeToSend()
  189.      *
  190.      * @return string  Time to send
  191.      * @access public
  192.      **/
  193.     function getTimeToSend()
  194.     {
  195.         return $this->time_to_send;
  196.     }
  197.  
  198.     /**
  199.      * Return mail sent time (if sended) else false.
  200.      *
  201.      * Mail_Queue_Body::getSentTime()
  202.      *
  203.      * @return mixed  String sent time or false if mail not was sent yet
  204.      * @access public
  205.      **/
  206.     function getSentTime()
  207.     {
  208.         return empty($this->sent_time) ? false : $this->sent_time;
  209.     }
  210.  
  211.     /**
  212.      * Return sender id.
  213.      *
  214.      * Mail_Queue_Body::getIdUser()
  215.      *
  216.      * @return integer  Sender id
  217.      * @access public
  218.      **/
  219.     function getIdUser()
  220.     {
  221.         return $this->id_user;
  222.     }
  223.  
  224.     /**
  225.      * Return sender ip.
  226.      *
  227.      * Mail_Queue_Body::getIp()
  228.      *
  229.      * @return string  IP
  230.      * @access public
  231.      **/
  232.     function getIp()
  233.     {
  234.         return stripslashes($this->ip);
  235.     }
  236.  
  237.     /**
  238.      * Return sender e-mail.
  239.      *
  240.      * Mail_Queue_Body::getSender()
  241.      *
  242.      * @return string E-mail
  243.      * @access public
  244.      **/
  245.     function getSender()
  246.     {
  247.         return stripslashes($this->sender);
  248.     }
  249.  
  250.     /**
  251.      * Return recipient e-mail.
  252.      *
  253.      * Mail_Queue_Body::getRecipient()
  254.      *
  255.      * @return string E-mail
  256.      * @access public
  257.      **/
  258.     function getRecipient()
  259.     {
  260.         return stripslashes($this->recipient);
  261.     }
  262.  
  263.     /**
  264.      * Return mail headers (in RFC)
  265.      *
  266.      * Mail_Queue_Body::getHeaders()
  267.      *
  268.      * @return mixed array|string headers
  269.      * @access public
  270.      **/
  271.     function getHeaders()
  272.     {
  273.         if (is_array($this->headers)) {
  274.             $tmp_headers = array();
  275.             foreach ($this->headers as $key => $value) {
  276.                 $tmp_headers[$key] = stripslashes($value);
  277.             }
  278.             return $tmp_headers;
  279.         }
  280.         return stripslashes($this->headers);
  281.     }
  282.  
  283.     /**
  284.      * Return mail body (in RFC)
  285.      *
  286.      * Mail_Queue_Body::getBody()
  287.      *
  288.      * @return string  Body
  289.      * @access public
  290.      **/
  291.     function getBody()
  292.     {
  293.         return stripslashes($this->body);
  294.     }
  295.  
  296.     /**
  297.      * Return how many times mail was try to sent.
  298.      *
  299.      * Mail_Queue_Body::getTrySent()
  300.      *
  301.      * @return integer  How many times mail was sent
  302.      * @access public
  303.      **/
  304.     function getTrySent()
  305.     {
  306.         return $this->try_sent;
  307.     }
  308.  
  309.     /**
  310.      * Return true if mail must be delete after send from db.
  311.      *
  312.      * MailBody::isDeleteAfterSend()
  313.      *
  314.      * @return bool  True if must be delete else false.
  315.      * @access public
  316.      **/
  317.     function isDeleteAfterSend()
  318.     {
  319.         return $this->delete_after_send;
  320.     }
  321.  
  322.     /**
  323.      * Increase and return try_sent
  324.      *
  325.      * Mail_Queue_Body::try()
  326.      *
  327.      * @return integer  How many times mail was sent
  328.      * @access public
  329.      **/
  330.     function try()
  331.     {
  332.         return ++$this->try_sent;
  333.     }
  334. }
  335. ?>